﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NBusiness.CodeDom.Services;
using System.Reflection;

namespace NBusiness.CodeDom.Services
{
    [Serializable]
    public class MethodData : MemberData
    {
        public MethodData() { }
        public MethodData(MethodInfo method)
        {
            Dictionary<string, TypeData> parameters = new Dictionary<string, TypeData>();
            foreach(ParameterInfo p in method.GetParameters())
                parameters.Add(p.Name, new TypeData(p.ParameterType));

            Name = method.Name;
            FullName = method.DeclaringType.FullName;
            DeclaringType = new TypeData(method.DeclaringType);
            ReturnType = new TypeData(method.ReturnType);
            Signature = parameters;
        }

        public TypeData ReturnType { get; set; }

        public Dictionary<string, TypeData> Signature { get; set; }

        public override bool Equals(object obj)
        {
            return obj.ToString() == ToString();
        }
    }
}
